/**
 * 
 */
package com.xbang.attendance.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xbang.attendance.service.UserManagerService;
import com.xbang.core.dao.support.GenericDaoSupport;
import com.xbang.core.service.impl.BaseServiceImpl;

/**
 * @author dev.zhang
 * 
 */
@Service("userManagerService")
public class UserManagerServiceImpl extends BaseServiceImpl implements UserManagerService {

	@Autowired
	private GenericDaoSupport genericDaoSupport;

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.xbang.attendance.service.UserManagerService#isDuplicateByUserName(java.lang.String)
	 */
	public boolean isDuplicateByUserName(String userName) throws Exception {

		String hqlSentence = "FROM User user WHERE user.name = :userName";

		Map<String, Object> parameters = new HashMap<String, Object>();
		parameters.put("userName", userName);

		List users = genericDaoSupport.searchForList(hqlSentence, parameters);

		return null == users || users.isEmpty() ? false : true;
	}

}
